/**
 * \file PropPageCtl.cpp
 *
 * \brief Implementation file for class CPropPageCtl
 *
 * $Id: PropPageCtl.cpp,v 1.1.1.1 2008/04/23 13:29:14 mgh Exp $
 *
 *
 * Copyright (C) 2006 Michael G. Herstine <sp1ff@pobox.com>
 *
 * Permission to use, copy, or modify this source code is hereby granted
 * free of  charge, provided  that this copyright  notice appear  on all
 * copies  and  on   all  source  code  derived  from   this  code.   No
 * representation is made regarding the suitability of this software for
 * any  purpose.  It  is provided  "as  is" without  express or  implied
 * warranty.
 *
 *
 */

#include "stdafx.h"             // Pre-compiled header
#include "SampleCAI.h"          // MIDL-generated bindings
#include "AddIn.h"              // Project header
#include "PropPageCtl.h"        // For class CPropPageCtl

////////////////////////////////////////////////////////////////////////
// Class CPropPageCtl

CPropPageCtl::CPropPageCtl()
{
  m_bWindowOnly = TRUE;
  CalcExtent(m_sizeExtent);
}

HRESULT CPropPageCtl::FinalConstruct()
{
  ATLTRACE2(atlTraceControls, 3, _T("CPropPageCtl::FinalConstruct\n"));
  return S_OK;
}

void CPropPageCtl::FinalRelease()
{
  ATLTRACE2(atlTraceControls, 3, _T("CPropPageCtl::FinalRelease\n"));
}

////////////////////////////////////////////////////////////////////////
// Interface IDTToolsOptionsPage

/**
 * \brief Occurs immediately after a custom Tools Options page is
 * created for the first time
 *
 *
 * \param pDTEObject The parent object of the Tools Options page,
 * namely, a DTE object
 *
 * \return This method always returns S_OK
 *
 *
 * After OnAfterCreated occurs, the custom Tools Options page is ready
 * to accept user input.
 *
 *
 */

STDMETHODIMP CPropPageCtl::OnAfterCreated(EnvDTE::_DTE * /*pDTEObject*/)
{
  ATLTRACE2(atlTraceControls, 3, _T("CPropPageCtl::OnAfterCreated\n"));
  return S_OK;
}

/**
 * \brief Returns an object containing all properties contained on the
 * specified custom Tools Options page.
 *
 *
 * \param pProperties The Tools Options object
 *
 *
 * When you call DTE.Properties("Root", "Page") and "Root" and "Page"
 * correspond to this control, then GetProperties is invoked and the
 * control creates a Properties collection. GetProperties can return
 * NULL if you do not want to implement properties, but it is to your
 * advantage that you do implement properties.
 *
 *
 */

STDMETHODIMP CPropPageCtl::GetProperties(/*[in, out]*/ IDispatch **pProperties)
{
  ATLTRACE2(atlTraceControls, 3, _T("CPropPageCtl::GetProperties\n"));

  *pProperties = NULL;

  return S_OK;
}

STDMETHODIMP CPropPageCtl::OnOK()
{
  ATLTRACE2(atlTraceControls, 3, _T("CPropPageCtl::OnOK\n"));

  CDlgMixin<CPropPageCtl>::OnClickedOK();
  setHelloPhrase(m_strHello);

  return S_OK;
}

STDMETHODIMP CPropPageCtl::OnCancel()
{
  ATLTRACE2(atlTraceControls, 3, _T("CPropPageCtl::OnCancel\n"));
  return S_OK;
}

STDMETHODIMP CPropPageCtl::OnHelp()
{
  ATLTRACE2(atlTraceControls, 3, _T("CPropPageCtl::OnHelp\n"));
  return S_OK;
}

////////////////////////////////////////////////////////////////////////

STDMETHODIMP CPropPageCtl::OnAmbientPropertyChange(DISPID dispid)
{
  if (dispid == DISPID_AMBIENT_BACKCOLOR)
  {
    SetBackgroundColorFromAmbient();
    FireViewChange();
  }

  return IOleControlImpl<CPropPageCtl>::OnAmbientPropertyChange(dispid);
}


////////////////////////////////////////////////////////////////////////

LRESULT CPropPageCtl::OnInitDialog(UINT   /*nMsg*/,
                                   WPARAM wParam,
                                   LPARAM lParam,
                                   BOOL  &bHandled)
{
  m_strHello = getHelloPhrase();

  CDlgMixin<CPropPageCtl>::OnInitDialog(wParam, lParam, bHandled);

  return 0L;
}

// Local Variables:
// fill-column: 72
// indent-tabs-mode: nil
// show-trailing-whitespace: t
// End:

// PropPageCtl.cpp ends here.
